#pragma rtGlobals=1 // Use modern global access method. //////////////////////// menu "RubyPressureMenu" "1: Show Ruby Pressure Tools", toolpanelopen() end proc toolpanelopen() variable/g ramda0=0, flag=0 dowindow/k toolpanel newpanel/w=(300,100,590,370) dowindow/c/t toolpanel, "Tool Panel" DrawText 24,26,"Tool Panel" SetDrawEnv fillfgc= (52224,52224,52224),fillpat= 1 drawrect 10,29,280,260 Button PLR, size={130, 30},pos={24,40},title="Get Pressure",proc = PLruby ValDisplay stdrp, size={230,30},pos={24,80},title="Standard ruby peak position (nm) :",value=ramda0 ValDisplay furagu, size={205,30},pos={24,100},title="Type of pressure equation : flag=",value=flag DrawText 24, 140,"flag=0 : get ruby standard peak position." DrawText 24, 160,"flag=1 : Piermarini equation." DrawText 24, 180,"flag=2 : Mao (non-hydrostatic) equation." DrawText 24, 200,"flag=3 : Mao (quasi-hydrostatic) equation." DrawText 24, 220,"flag=4 : Mao (hydrostatic) equation." DrawText 24, 240,"** If you change the type of equation, " DrawText 27, 252, "you write like (flag=0) in command line." SetDrawEnv fillpat= 0 end function PLruby(ctrname) : buttoncontrol string ctrname nvar ramda0 nvar flag //flag=0-4 variable i=3 variable s=0, B=0, A=0, bgd=0, x0=0, press=0 variable startp=0, endp=0 if(!waveexists(csrwaveref(A)) || !waveexists(csrwaveref(B)) ) doalert 0, "No cursor on the PL wave." return 0 endif if(flag==0) doalert 1, "From now, standard R1 ruby peak position (ramda0) is calculated." if (V_Flag==2) return 0 endif endif if(pcsr(a) < pcsr(b)) wavestats/q/r=(pcsr(a), pcsr(b)) csrwaveref(a) else wavestats/q/r=[pcsr(b), pcsr(a)] csrwaveref(a) endif A=V_max x0=csrxwaveref(a)[V_maxloc] bgd=(vcsr(a)+vcsr(b))/2 B=(A+bgd)/2 s=0.2 //if peak intensity is too low, fitting do not act. if(A<(bgd*1.1)) doalert 0, "It is too low the line to be fitted." return 0 endif //fitting range is X0 +- i. i=2 //If the value of Y(startp) is low than A*0.9, fitting range is increased. i=i+1 do startp=V_maxloc - i endp=V_maxloc + i if(csrwaveref(a)[startp] <= A*0.9 && csrwaveref(a)[endp] <= A*0.9) break endif i=i+1 while(1) //fitting algorizm zone make/d/o/n=4 coef coef[0]=A coef[1]=B coef[2]=x0 coef[3]=s FuncFit/h="0100" RubyFitFunc coef csrwaveref(a)[startp,endp] /X=$csrxwave(a)/d string temp="fit_" + csrwave(a) ModifyGraph lsize($temp)=3,rgb($temp)=(19890,21913,52784) //return pressure(GPa) value if(flag==0) ramda0=coef[2] flag=1 print "Standad ruby R1 peak position is " + num2str(ramda0) + " (nm)" KillWaves/z W_coef,W_sigma,W_ParamConfidenceInterval,coef return 0 elseif(flag==1) press=2.74*(coef[2]-ramda0) //Piermarini equation print "This pressure is " + num2str(press) + " (GPa)" elseif(flag==2) press=(1904/5)*((1+(coef[2]-ramda0)/ramda0)^5-1) //Mao-non (non hydrostatic) print "This pressure is " + num2str(press) + " (GPa)" elseif(flag==3) press=(1904/7.665)*((1+(coef[2]-ramda0)/ramda0)^7.665-1) //Mao-quasi (quasi-hydrostatic) print "This pressure is " + num2str(press) + " (GPa)" elseif(flag==4) press=(1904/7.715)*((1+(coef[2]-ramda0)/ramda0)^7.715-1) //Mao-hydro (hydrostatic) print "This pressure is " + num2str(press) + " (GPa)" else doalert 0, "Flag value is not correct. You change correct flag value." endif KillWaves/z W_coef,W_sigma,W_ParamConfidenceInterval,coef doalert 0, "This Pressure is " + num2str(press) + " (GPa)" end function RubyFitFunc(w,x) : fitfunc Wave w Variable x return (w[0]-w[1])*exp(-((x-w[2])/(2*w[3]))^2)+w[1] end